<style type="text/css"> 
b.green{color:DarkGreen;}
b.red  {color:#880000;}
b.code {background:#f9edd4;}
p.code {background:#f9edd4;}
body   {background:#e2fbe4;}
</style><body><pre>
<h3>Kurs: 04 Turtle</h3>
Script 1: Textausgabe.
Script 2: Turtledaten abfragen und anzeigen.


<u>Erklrungen zum Script</u>

* Textausgabe
  <b class="code">t.text("Text");</b>
  <i>"Text" an der Turleposition mit Richtung ausgeben.</i>
  
  <b class="code">t.text(x,y, "Text");</b>
  <i>"Text" bei Punkt (x,y) mit Richtung ausgeben.</i>
  
  <b class="code">t.text(x0,y0,  x1,y1, "Text" );</b>
  <i>"Text" im Rechteck(x0,y0, x1,y1) formatiert
  an der Turleposition mit Richtung ausgeben.</i>

  <b class="code">t.setFont("FontName", size_mm, FixPitch=true, Weight=50 ); </b>
  <i>Schrifttyp und H&ouml;he setzen.
  "FontName" siehe Einstellungen. Weight 0-99</i>

__________________________________________
<p class="code"><code>
ScriptBegin
var Grafik="Script Turtle";

function init() //Initialisierungen
{ t.setBrush("LightBlue");
  t.setPage(4);
} 

function draw() //Zeichenbefehle
{ // t.drawKoordSystem();
  // t.drawRaster();
  
  t.goTo(-130,90); t.turnTo(-90);
  t.setPen("red"); t.setFont("Arial",15);
  t.text("Texte ausgeben ...");

  t.turnTo(-20);  
  t.setPen("green"); t.setFont("Arial",5);
  t.text(-100,-15,"Text auf Position ausgeben"); 

  t.turnTo(0);
  t.goTo(-50,-40); t.rectangle(110,120); 
  t.setPen("black"); t.setFont("Courier",3);
  t.text(-50,80, 60,-40,
         "TextBox: \n\n" + t.infoScript());  
}
ScriptEnd </code></p>
__________________________________________

Script 2: Turtledaten abfragen und anzeigen.
          Debuggen.

<u>Erklrungen zum Script</u>

* Turtledaten
  <b class="code">t.lastX();</b> <i>Aktuelle x-Koordinate der Turtle.</i>
  <b class="code">t.lastY();</b> <i>Aktuelle y-Koordinate der Turtle.</i>
  <b class="code">t.lastW();</b> <i>Aktuelle Bickrichtung der Turtle in Grad.</i>
  
  <b class="code">t.getL();</b> <i>Betrag des Vektors (0,0)->(lastX(),lastY()).</i>
  <b class="code">t.getW();</b> <i>Richtung des Vektors (0,0)->(lastX(), lastY()).</i>
   
* Daten in der MsgBox ausgeben 
  <b class="code">t.clrMsg();</b> <i>MsgBox lschen.</i>
  
  <b class="code">t.msg( Meldung );</b>
  <i>Text oder Zahlen (Variant) in der MsgBox anzeigen.</i>

  <b class="code">t.msgScript(showWerte=true);</b>
  <i>true:  Script-Objekte und Werte in der MsgBox anzeigen.
  false: Nur Script-Objekte anzeigen.</i>
     
  <b class="code">t.msgPolygon();</b>
  <i>Polygon als Funktion in der MsgBox anzeigen.</i>


<p class="code"><code>ScriptBegin
var Grafik="Script Turtle";

function init() //Initialisierungen
{} 

function draw() //Zeichenbefehle
{
  t.setPen("red");
  t.turnTo(-52.5); t.move(75); t.turnTo(73);
  
  t.clrMsg();
  t.msg("Punkt Last(" + t.lastX() + ", " + t.lastY() + ")" );
  t.msg("Vektor Last Lnge = " + t.getL());
  t.msg("Vektor Last Richtung = " + t.getW() );
  t.msg("======================================","blue");
  t.msg("Turtle Richtung = " + t.lastW());
  t.msg("======================================","blue");

  t.msgTurtle();  
  t.msg("======================================","blue");
  
  t.msgScript(false);
  t.msg("======================================","blue");
  
  t.msgScript();
  t.msg("======================================","blue");
  
  t.msgPolygon();
}
ScriptEnd </code></p>